<template>
  <el-dialog  :visible.sync="isShow" center class="earnings-settlement" append-to-body width="60%" :before-close="handleClose">
    <el-table class="detail-table" :data="settlementData" border max-height="350" style="width: 100%" ref="table">
      <el-table-column prop="name" label="原因" show-overflow-tooltip min-width="140">
        <template slot-scope="scope">
          <span v-if="type == 1">
            {{ scope.row.deduction && scope.row.deduction.name }}
          </span>
          <span v-else>{{ scope.row.reward && scope.row.reward.reason }}</span>
        </template>
      </el-table-column>
      <el-table-column prop="prices" label="金额" show-overflow-tooltip min-width="140">
        <template slot-scope="scope">
          <span v-if="type == 1">
            {{ scope.row.deduction && scope.row.deduction.deduction_price }}
          </span>
          <span v-else>{{ scope.row.reward && scope.row.reward.reward }}</span>
        </template>
      </el-table-column>
    </el-table>
  </el-dialog>
</template>

<script>
export default {
  data () {
    return {
      isShow:false,
      settlementData: [],
      settlement_id: null,
      type: 1,
    }
  },
  methods: {
    show(data, type) {
      this.settlement_id = data.id;
      this.type = type
      this.getInfo(type);
      this.isShow = true;
    },
    handleClose () {
      this.settlementData = []
      this.isShow = false
    },
    getInfo(type) {
      this.$axios.get(`api/settlement/${this.settlement_id}`).then(res => {
        if (res.data.code == 200) {
          this.settlementData.push(res.data.data)
          // if (data.final && data.final.settlement_reward_record) {
          //   this.settlementData = data.final.settlement_reward_record
          // } else {
          //   this.$alert('该案件暂无结算详情', "提示", {
          //     confirmButtonText: "确定",
          //     center: true,
          //     type: "warning",
          //     callback: action => {}
          //   });
          // }
          // if (type == 1) {
          //   this.settlementData = data.deduction
          // } else {
          //   this.settlementData = data.reward
          // }
        } else {
          this.$alert(res.data.message, "提示", {
            confirmButtonText: "确定",
            center: true,
            type: "warning",
            callback: action => {}
          });
        }
      });
    },
    // refresh() {
    //   this.isShow = false;
    //   this.$emit("refresh");
    // },
  }
}
</script>

<style lang='less'>
  .earnings-settlement {

  }
</style>